package com.example.lenovo.demo.presenter.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.lenovo.demo.R;
import com.example.lenovo.demo.model.databean.StrategyBean;

import java.util.List;

/**
 * Created by Lenovo on 2017/1/15.
 */

public class StrategyChildRv_Rvitem_RvImgAdapter extends RecyclerView.Adapter<StrategyChildRv_Rvitem_RvImgAdapter.ViewHolder>{
    private List<StrategyBean.PagesBean.ChildrenBean.SectionsBean.PhotosBean> data;
    private Context context;

    public StrategyChildRv_Rvitem_RvImgAdapter(List<StrategyBean.PagesBean.ChildrenBean.SectionsBean.PhotosBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public StrategyChildRv_Rvitem_RvImgAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.strategychild_rvitem_item_rvimg,parent,false));
    }

    @Override
    public void onBindViewHolder(StrategyChildRv_Rvitem_RvImgAdapter.ViewHolder holder, int position) {
        Log.e("msg",data.get(position).getImage_url());
        Glide.with(context).load(data.get(position).getImage_url()).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return data==null?0:data.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        public ViewHolder(View itemView) {
            super(itemView);
            imageView= (ImageView) itemView.findViewById(R.id.strategy_child_rvitem_rvimg);
        }
    }
}
